﻿using System.Collections.Generic;
using System.Linq;

namespace Sharp.Framework.Queries
{
    /// <summary>
    /// 数据查询接口
    /// </summary>
    public interface IQuery
    {
        /// <summary>
        /// 获取对象
        /// </summary>
        /// <typeparam name="T">对象类型</typeparam>
        /// <typeparam name="TKey">对象主键类型</typeparam>
        /// <param name="id">对象标识</param>
        /// <returns></returns>
        T Get<T, TKey>(TKey id);

        /// <summary>
        /// 获取对象
        /// </summary>
        /// <typeparam name="T">对象类型</typeparam> 
        /// <param name="id">对象标识</param>
        /// <returns></returns>
        T Get<T>(int id);


        /// <summary>
        /// 获取对象查询列表
        /// </summary>
        /// <typeparam name="T">对象类型</typeparam>
        /// <returns></returns>
        IQueryable<T> FindAll<T>();


      /// <summary>
        /// 存储过程查询
      /// </summary>
        /// <typeparam name="T">对象类型</typeparam>
      /// <param name="name">存储过程名</param>
      /// <param name="paras">存储过程参数</param>
      /// <returns></returns>
        IList<T> Exec<T>(string name, IDictionary<string, object> paras);
        /// <summary>
        /// 存储过程查询
        /// </summary>
        /// <typeparam name="T">对象类型</typeparam>
        /// <param name="name">存储过程名</param>
        /// <param name="paras">存储过程参数</param>
        /// <returns></returns>
        void Exec(string name, IDictionary<string, object> paras);
        /// <summary>
        /// 保存对象
        /// </summary>
        /// <param name="entity"></param>
        void Save<T>(T entity);
        /// <summary>
        /// 删除对象
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entity"></param>
        void Delete<T>(T entity);
    }
}